import 'package:dk_flutter_base/dk_core.dart';
import 'package:dk_flutter_base/src/core/util/data_util.dart';
import 'package:flutter/material.dart';

class TestBase64 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    String base64 =
        "aHR0cDovLzE3Mi4xOC4xMzAuMTg6ODE5MC9wYW5ndS1zYWxlci9hcGkvY3NhbGVyL3YzL3N5c3RlbS1saXN0L2NvbXBvbmVudC1jb25maWc_dHlwZT1kYWlrYW4tc2NoZWR1bGU";
    String toBase64 =
        "http://172.18.130.18:8190/pangu-saler/api/csaler/v3/system-list/component-config?type=daikan-schedule";

    Map<String, String> params = {
      "key1111": "1",
      "key2": "2",
      "key3": "3",
    };

    String nativeRoute = "dkwidget://app/common/secondSaleNameList?key0=0";
    Uri uri = Uri.tryParse(nativeRoute);
    StringBuffer sb = StringBuffer();
    sb.write(uri.scheme);
    sb.write(uri.host);
    sb.write(uri.path);

    Map<String, dynamic> paramsMap = Map<String, dynamic>();
    if (mapNotEmpty(uri.queryParameters)) {
      print("------------------");
      paramsMap.addAll(uri.queryParameters);
    }
    if (mapNotEmpty(params)) {
      paramsMap.addAll(params);
      print("=====================");
    }

    return Scaffold(
      appBar: AppBar(
        elevation: 0.0,
        title: Text('我是主界面'),
      ),
      body: Column(
        children: <Widget>[
          Text("编码："),
          Text(dkEncodeBase64(toBase64)),
          Text("解码："),
          Text(dkDecodeBase64(base64)),
          Text("map："),
          Text(paramsMap.length.toString()),
          Text("map："),
          Text(paramsMap.toString()),
        ],
      ),
    );
  }
}
